

import sys, os
os.chdir('..')
sys.path.append('..')


import pyrind
from pyrind import RWindow
import testcase
	
class MyApplication():
	def __init__(self,w):
		w.title = 'Welcome'
		
		#use a grid, because can specify minimum size/width
		f = w.begin_frame()
		f.set_row_weight(0,minsize=300)
		f.set_col_weight(0,minsize=300)
		with w.add_frame(grid=(0,0)):
			self.btn1 = w.add_button('One')
			w.add_button('Two')
			w.add_button('Three')
		
		w.end_frame()
		
		w.begin_frame()
		otestcase = testcase.TestCaseOpt(w)
		otestcase.addProperty(self.btn1, 'text', ['changing text','underline &text','some\ntext\nwith\nnew lines','a really long line of text that continues'])
		#~ otestcase.addProperty(self.btn1, 'icon', [None, otestcase.img1,otestcase.img2 ])
		otestcase.addProperty(self.btn1, 'icon_position', ['center','left','right','top','bottom' ])
		otestcase.addProperty(self.btn1, 'onclick', [None, self.handler1,self.handler2 ])
		otestcase.addProperty(self.btn1, 'enabled', [True, False ])
		otestcase.addProperty(self.btn1, 'height', [0,1,2,3 ])
		otestcase.addProperty(self.btn1, 'width',  [0,10,20,30,40,50,60 ])
		
		otestcase.addRow()
		otestcase.addProperty(self.btn1, 'borderstyle', ['sunken','raised','groove','ridge','flat'])
		otestcase.addProperty(self.btn1, 'defaultstyle', [True, False ])
		otestcase.addProperty(self.btn1, 'borderwidth', [0,1,2,3,4 ])
		otestcase.addProperty(self.btn1, 'font', [None, 'times','helvetica','courier', ('Lucida Console', 16, 'normal'),('Verdana', 6, 'normal') ])
		#unfortunately, no clear way to return to TkDefaultFont
		otestcase.addProperty(self.btn1, 'anchor', ['center','top','topright','right','bottomright','bottom','bottomleft','left','topleft'])
		
		
		otestcase.addRow()
		otestcase.addProperty(self.btn1, 'bgcolor', ['black','red',(255,0,64), (255,0,128)])
		otestcase.addProperty(self.btn1, 'color', ['black','red',(255,0,64), (255,0,128)])
		otestcase.addProperty(self.btn1, 'activebgcolor', ['black','red',(255,0,64), (255,0,128)])
		otestcase.addProperty(self.btn1, 'activecolor', ['black','red',(255,0,64), (255,0,128)])
		
		otestcase.addRow()
		otestcase.addProperty(self.btn1, 'wrapwidth',  [0,10,20,30,40,50,60 ])
		otestcase.addProperty(self.btn1, 'alignment',  ['left','right','center' ])
		
		otestcase.addRow()
		otestcase.addMethod('call',lambda: self.btn1.call())
		otestcase.addMethod('set_icondata',lambda: self.btn1.set_icon_base64(otestcase.img1data))
		otestcase.addMethod('set_iconnone',lambda: self.btn1.set_icon_base64(None))
		otestcase.addMethod('show_only_icon',lambda: self.btn1.show_only_icon(True))
		otestcase.addMethod('show_only_icon',lambda: self.btn1.show_only_icon(False))
		# check "round trips" on these settings by seeing reported.
		
		w.end_frame()
		
		w.start()
		
	def handler1(self):
		print 'handler1'
		
	def handler2(self):
		print 'handler2'


app = MyApplication(RWindow())

